 <?php 
 /**
  * 
  * 这一页,是被CHECK OUT DEFAULT 所包含的表单内容.
  */
 ?>

	<div class="order_wrapper">
  	<h2><img src="images/order/tit_delivery.png" />
  	<span>请仔细检查你的送货地址，你也可以修改送货地址，下次购物将会有最近的历史记录。</span>
  	</h2>
  	
  	<?php if ($messageStack->size('checkout_shipping') > 0) echo $messageStack->output('checkout_shipping'); ?>  
    	<p class="delivery_address">
        <?php echo html_entity_decode(zen_address_label($_SESSION['customer_id'], $_SESSION['sendto'], true, ' ', '<br />')); ?>
     
      <?php if ($displayAddressEdit) { ?>
      <?php 
              echo '<a class="btn_delivery" href="' . zen_href_link(FILENAME_CHECKOUT_SHIPPING_ADDRESS, '', 'SSL') . '"></a>';
      ?>
      <?php } ?>
      </p>
      <br class="clearBoth" />
    </div>
  
  <div class="order_wrapper">
    	<h2><img src="images/order/tit_payment.png" /><span>请选择适合你的付款方式，我们的付款系统保证付款过程安全，请安心使用。</span></h2>
            
      <div class="order_wrapper">
        <?php
        if (SHOW_ACCEPTED_CREDIT_CARDS != '0') {
      ?>
      
      <?php
          if (SHOW_ACCEPTED_CREDIT_CARDS == '1') {
            echo TEXT_ACCEPTED_CREDIT_CARDS . zen_get_cc_enabled();
          }
          if (SHOW_ACCEPTED_CREDIT_CARDS == '2') {
            echo TEXT_ACCEPTED_CREDIT_CARDS . zen_get_cc_enabled('IMAGE_');
          }
      ?>
      <br class="clearBoth" />
      <?php } ?>
      
      <?php
        foreach($payment_modules->modules as $pm_code => $pm) {
          if(substr($pm, 0, strrpos($pm, '.')) == 'googlecheckout') {
            unset($payment_modules->modules[$pm_code]);
          }
        }
        $selection = $payment_modules->selection();
      
        if (sizeof($selection) > 1) {
      ?>
      <p class="important"><?php echo TEXT_SELECT_PAYMENT_METHOD; ?></p>
      <?php
        } elseif (sizeof($selection) == 0) {
      ?>
      <p class="important"><?php echo TEXT_NO_PAYMENT_OPTIONS_AVAILABLE; ?></p>
      
      <?php
        }
      ?>
      
      <?php
        $radio_buttons = 0;
        for ($i=0, $n=sizeof($selection); $i<$n; $i++) {
      ?>
      <?php
          if (sizeof($selection) > 1) {
              if (empty($selection[$i]['noradio'])) {
       ?>
      <?php echo zen_draw_radio_field('payment', $selection[$i]['id'], ($selection[$i]['id'] == $_SESSION['payment'] ? true : false), 'id="pmt-'.$selection[$i]['id'].'"'); ?>
      <?php   } ?>
      <?php
          } else {
            
      ?>
      <?php echo zen_draw_hidden_field('payment', $selection[$i]['id']); ?>
      <?php
          }
      ?>
      <label for="pmt-<?php echo $selection[$i]['id']; ?>" class="radioButtonLabel"><?php echo $selection[$i]['module']; ?></label>
      
      <?php
          if (defined('MODULE_ORDER_TOTAL_COD_STATUS') && MODULE_ORDER_TOTAL_COD_STATUS == 'true' and $selection[$i]['id'] == 'cod') {
      ?>
      <div class="alert"><?php echo TEXT_INFO_COD_FEES; ?></div>
      <?php
          } else {
            // echo 'WRONG ' . $selection[$i]['id'];
      ?>
      <?php
          }
      ?>
      <br class="clearBoth" />
      
      <?php
          if (isset($selection[$i]['error'])) {
      ?>
          <div><?php echo $selection[$i]['error']; ?></div>
      
      <?php
          } elseif (isset($selection[$i]['fields']) && is_array($selection[$i]['fields'])) {
      ?>
      
      <div class="ccinfo">
      <?php
            for ($j=0, $n2=sizeof($selection[$i]['fields']); $j<$n2; $j++) {
      ?>
      <label <?php echo (isset($selection[$i]['fields'][$j]['tag']) ? 'for="'.$selection[$i]['fields'][$j]['tag'] . '" ' : ''); ?>class="inputLabelPayment"><?php echo $selection[$i]['fields'][$j]['title']; ?></label><?php echo $selection[$i]['fields'][$j]['field']; ?>
      <br class="clearBoth" />
      <?php
            }
      ?>
      </div>
      <br class="clearBoth" />
      <?php
          }
          $radio_buttons++;
      ?>
      <br class="clearBoth" />
      <?php
        }
      ?>
      <!-- bof Gift Wrap -->
      <?php 
        if (FEC_GIFT_WRAPPING_SWITCH == 'true') {
          if (!file_exists(DIR_WS_MODULES . "order_total/ot_giftwrap_checkout.php")) {
            echo '<font color="red"><strong>GIFTWRAP MODULE NOT INSTALLED, PLEASE DISABLE IN FEC CONFIGURATION</strong></font>';
          } else {     
      ?>
      <?php
         $value = "ot_giftwrap_checkout.php"; 
         include_once(zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] .
                '/modules/order_total/', $value, 'false'));
         include_once(DIR_WS_MODULES . "order_total/" . $value);
         $wrap_mod = new ot_giftwrap_checkout(); 
         $use_gift_wrap = true;
         if ($wrap_mod->check()) {
      ?>
            <br />
      <fieldset class="shipping" id="gift_wrap">
      <legend><?php echo GIFT_WRAP_HEADING; ?></legend>
      <?php
          echo '<div id="cartWrapExplain">'; 
          echo '<a href="javascript:alert(\'' . GIFT_WRAP_EXPLAIN_DETAILS . '\')">' . GIFT_WRAP_EXPLAIN_LINK . '</a>';
          echo '</div>'; 
      ?>
            <table border="0" width="100%" cellspacing="0" cellpadding="0">
              <tr class="cartTableHeading">
                <th scope="col" id="ccWrapProductsHeading"><?php echo TABLE_HEADING_PRODUCTS; ?></th>
                <th scope="col" id="ccWrapHeading"><?php echo GIFT_WRAP_CHECKOFF; ?></th>
              </tr>
      <?php  
             // now loop thru all products to display quantity and price
         $prod_count = 1; 
      // tsg_logger($order->products); 
         for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
           for ($q = 1; $q <= $order->products[$i]['qty']; $q++) {
              if ($prod_count%2 == 0) {
                 echo '<tr class="rowEven">';
              } else {
                 echo '<tr class="rowOdd">';
              }
              echo '<td class="cartProductDisplay">' . $order->products[$i]['name'];
      
              // if there are attributes, loop thru them and display one per line
              if (isset($order->products[$i]['attributes']) && sizeof($order->products[$i]['attributes']) > 0 ) {
                  echo '<ul class="cartAttribsList">';
                  for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {
                      echo '<li>' . $order->products[$i]['attributes'][$j]['option'] . ': ' . nl2br($order->products[$i]['attributes'][$j]['value']) . '</li>'; 
                  } // end loop
                  echo '</ul>';
              } // endif attribute-info
      ?>
              </td>
      <?php
               // gift wrap setting
               echo '<td class="cartWrapCheckDisplay">'; 
               $prid = $order->products[$i]['id'];
               if (zen_get_products_virtual($order->products[$i]['id'])) {
                  echo GIFT_WRAP_NA;
               } else if (DOWNLOAD_ENABLED && product_attributes_downloads_status($order->products[$i]['id'], $order->products[$i]['attributes'])) {
                  echo GIFT_WRAP_NA; 
               } else if ($wrap_mod->exclude_product($prid)) {
                  echo GIFT_WRAP_NA; 
               } else if ($wrap_mod->exclude_category($prid)) {
                  echo GIFT_WRAP_NA; 
               } else { 
                  $gift_id = "wrap_prod_" . $prod_count;
                  if (isset($_SESSION[$gift_id]) && $_SESSION[$gift_id] != '') $giftChecked = true; else $giftChecked = false;
                  echo zen_draw_checkbox_field($gift_id,'',$giftChecked, 'id="'.$gift_id .'" onclick="updateForm();"');
               }
               echo "</td>"; 
      ?>
            </tr>
      <?php
                  $prod_count++; 
               }
             }  // end for loopthru all products 
      ?>
            </table>
      </fieldset>
            <br />
      <?php
         }  
      ?>
      <?php }} ?>
      <!-- eof Gift Wrap -->
      <!-- bof doublebox -->
      <?php
        if (MODULE_ORDER_TOTAL_DOUBLEBOX_STATUS == 'true') {
          $value = "ot_doublebox_checkout.php"; 
          include_once(zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] .
                '/modules/order_total/', $value, 'false'));
          include_once(DIR_WS_MODULES . "order_total/" . $value);
          $doublebox_mod = new ot_doublebox_checkout(); 
          $use_doublebox = true;
          if ($doublebox_mod->check() && $doublebox_mod->enabled) {
      ?>
            <br />
            <hr />
      <fieldset class="shipping" id="doublebox">
      <legend><?php echo DOUBLEBOX_HEADING; ?></legend>
      <?php
          echo '<div id="cartDoubleBoxExplain">'; 
          echo '<a href="javascript:alert(\'' . DOUBLEBOX_EXPLAIN_DETAILS . '\')">' . DOUBLEBOX_EXPLAIN_LINK . '</a>';
          echo '</div>'; 
      ?>
            <table border="0" width="100%" cellspacing="0" cellpadding="0" id="cartContentsDisplay">
              <tr class="cartTableHeading">
              <th scope="col" id="ccProductsHeading"><?php echo TABLE_HEADING_PRODUCTS; ?></th>
               <th scope="col" id="ccDoubleBoxHeading"><?php echo DOUBLEBOX_CHECKOFF; ?></th>
              </tr>
      <?php  
             // now loop thru all products to display quantity and price
         $prod_count = 1; 
      // tsg_logger($order->products); 
         for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
           for ($q = 1; $q <= $order->products[$i]['qty']; $q++) {
              if ($prod_count%2 == 0) {
                 echo '<tr class="rowEven">';
              } else {
                 echo '<tr class="rowOdd">';
              }
              echo '<td class="cartProductDisplay">' . $order->products[$i]['name'];

              // if there are attributes, loop thru them and display one per line
              if (isset($order->products[$i]['attributes']) && sizeof($order->products[$i]['attributes']) > 0 ) {
                  echo '<ul class="cartAttribsList">';
                  for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {
                      echo '<li>' . $order->products[$i]['attributes'][$j]['option'] . ': ' . nl2br($order->products[$i]['attributes'][$j]['value']) . '</li>'; 
                  } // end loop
                  echo '</ul>';
              } // endif attribute-info
      ?>
              </td>
      <?php
               // doublebox setting
               echo '<td class="cartDoubleBoxCheckDisplay">'; 
               $prid = $order->products[$i]['id'];
               if (zen_get_products_virtual($order->products[$i]['id'])) {
                  echo DOUBLEBOX_NA;
               } else if (DOWNLOAD_ENABLED && product_attributes_downloads_status($order->products[$i]['id'], $order->products[$i]['attributes'])) {
                  echo DOUBLEBOX_NA; 
               } else if ($doublebox_mod->exclude_product($prid)) {
                  echo DOUBLEBOX_NA; 
               } else if ($doublebox_mod->exclude_category($prid)) {
                  echo DOUBLEBOX_NA; 
               } else { 
                  $doublebox_id = "doublebox_prod_" . $prod_count;
                  echo zen_draw_checkbox_field($doublebox_id,'1',$_SESSION[$doublebox_id], 'id="'.$doublebox_id .'"');
               }
               echo "</td>"; 
      ?>
            </tr>
      <?php
                  $prod_count++; 
               }
             }  // end for loopthru all products 
      ?>
            </table>
      </fieldset>
            <hr />
            <br />
      <?php
         }
        }  
      ?>
      <!-- eof doublebox -->     

    	</div>
            
            <!-- 
            <table width="100%" border="0">
              <tr>
                <td valign="middle"><img src="images/order/payment_03.gif" /></td>
                <td valign="middle"><img src="images/order/payment_04.gif" /></td>
                <td valign="middle"><img src="images/order/payment_01.gif" /></td>
                <td valign="middle"><img src="images/order/payment_02.gif" /></td>
              </tr>
              
              <tr>
                <td><input type="radio" name="payment" />推荐，全场免运费</td>
                <td><input type="radio" name="payment" />推荐，全场免运费</td>
                <td><input type="radio" name="payment" />货到付款，需加15元运费</td>
                <td><input type="radio" name="payment" />银行转账，需加15元运费</td>
              </tr>
            </table>
        -->
    </div>
  
  	<div class="order_wrapper">
          <h2><img src="images/order/tit_remarks.png" /><span>如果你有特殊要求，请在输入框中写明，我们会妥善处理你的要求！</span></h2>
          <?php echo zen_draw_textarea_field('comments', '45', '3','','class="ipt_remarks"'); ?>
          
    </div>
    
    
  
  <?php
    if (DISPLAY_CONDITIONS_ON_CHECKOUT == 'true') {
  ?>
  <fieldset class="checkout" id="checkoutConditions">
  <legend><?php echo TABLE_HEADING_CONDITIONS; ?></legend>
  <div><?php echo TEXT_CONDITIONS_DESCRIPTION;?></div>
  <?php echo  zen_draw_checkbox_field('conditions', '1', false, 'id="conditions"');?>
  <label class="checkboxLabel" for="conditions"><?php echo TEXT_CONDITIONS_CONFIRM; ?></label>
  </fieldset>
  <?php
    }
  ?>
  <!-- include hidden payment attributes -->
  <?php 
    if (is_array($payment_modules->modules)) {
      echo $payment_modules->process_button();
    }
  ?>